#!/usr/bin/env node

const koa = require('koa');

const Router = require('koa-router');

const app = new koa();
const router = new Router();

app.use((ctx,next)=>{
  console.log(`${ctx.method} ${ctx.path}`)
  next();
})

app.use((ctx,next)=>{
  const start = Date.now();
  next();
  const end = Date.now();
  console.log(`cost:${end-start}ms`)
})
  router.get('/api/authors/',async(ctx)=>{
    ctx.body = '得到漫画书作者列表'
  })
  router.get('/api/authors/:authorName/',async(ctx)=>{
    ctx.body = '按作者名称查询'
  })
  router.post('/api/authors/',async(ctx)=>{
    ctx.body = '添加新的漫画书作者'
  })
  router.put('/api/authors/:id',async(ctx)=>{
    ctx.body = ' 修改某 ID 的漫画书作者信息 '
  })
  router.delete('/api/authors/:id',async(ctx)=>{
    ctx.body = '删除某 ID 的漫画书作者信息'
  })
app.use(router.routes());
app.listen(3000);
